import React, { Component } from 'react'

export default class button extends Component {
    constructor(props){
        super(props)
        this.state = {
            count:0
        }
    }
    render() {
        return (
            <div>
                <CountBtn increment={e => this.increment()}></CountBtn>
                <div>计数：{this.state.count}</div>
                <button onClick={e => this.increment()}>新增</button>
            </div>
        )
    }
    increment(){
        console.log('2zz')
        this.setState({
            count:this.state.count+1
        })
    }
}

class CountBtn extends Component{
    render(){
        const {increment}= this.props
        return (
            <div>
                <button onClick={increment}>+1</button>
            </div>
        )
    }
}
